from django.test import TestCase

# Create your tests here.

# 单例模式
# class A(object):
#     def __new__(cls, *args, **kwargs):
#         if not hasattr(cls, 'instance'):
#             cls.instance = super(A, cls).__new__(cls)
#         return cls.instance
#
# s1= A()
# s2 = A()
# print(s1,s2)
# print(id(s1), id(s2))


# Monostate单例模式
# # 基于所有对象共享相同状态
# class Brog:
#     __shared_state = {'1':'2'}
#     def __init__(self):
#         self.x = 1
#         # self.__dict__ = self.__shared_state
#
# b1 = Brog()
# b2 = Brog()
# print(b1, b2)
#
# b1.x =4
# print(b1.__dict__)
# print(b2.__dict__)

# import pika
#
#
# credentials = pika.PlainCredentials('yrq', '123456')
# connection = pika.BlockingConnection(
#     pika.ConnectionParameters(host='120.78.12.187', credentials=credentials)
# )
#
# channel = connection.channel()
# channel.queue_declare(queue='que1')
# channel.basic_publish(exchange='',
#                       routing_key='que1',
#                       body='hello w')
# connection.close()
